using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAimSwordState : PlayerState
{
    public PlayerAimSwordState(Player player, PlayerStateMachine playerStateMachine, string animBoolName) : base(player, playerStateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        player.skill.swordSkill.DotActive(true);
    }

    public override void Exit()
    {
        base.Exit();
        player.StartCoroutine("IsBusy", .2f);
    }

    public override void Update()
    {
        base.Update();
        player.SetZeroVelocity();
        if (Input.GetMouseButtonUp(1))
            playerStateMachine.ChangeState(player.playerIdleState);
        PlayerFlip();
    }
    private void PlayerFlip()
    {
        Vector2 mouthPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        if (mouthPos.x > player.transform.position.x && player.faceDir == -1)
        {
            player.Flip();
        }
        else if (mouthPos.x < player.transform.position.x && player.faceDir == 1)
        {
            player.Flip();
        }
    }
}
